/**
 * 
 */
package com.gragra.functionalIdentification;
import com.gragra.data.Corpus;
import com.gragra.frameStatistics.CoOccurrenceStatistics;
import com.gragra.frameStatistics.StatisticsGenerator;
import com.gragra.nounIdentification.ConvergenceByIterations;
import com.gragra.nounIdentification.IncreasingMaxWithMin;
import com.gragra.nounIdentification.LinearIncreasingMax;
import com.gragra.nounIdentification.NounIdentifier;
import com.gragra.nounIdentification.Scorer;
import com.gragra.sampling.sequentialStructure.ExtensionInformationHolder;
import com.gragra.sampling.sequentialStructure.ExtensionInformationValue;
import com.gragra.sampling.sequentialStructure.ExtensionLevels;
import com.gragra.sampling.sequentialStructure.WordAndTagHolder;
import com.gragra.sampling.sequentialStructure.WordType;

/**
 * @author Christoph Teichmann
 * 04.09.2013
 */
public class FunctionalWordIdentifier extends NounIdentifier
{
	/**
	 * 
	 * @param data
	 * @param frameSize
	 * @param preMarkers
	 * @param postMarkers
	 * @param maxFrames
	 * @param maxWords
	 */
	public FunctionalWordIdentifier(Corpus<WordAndTagHolder> data,
			int frameSize, int preMarkers, int postMarkers, int maxFrames, int maxWords)
	{super(data, frameSize, preMarkers, postMarkers, new LowTypeTokenScorer(), new ConvergenceByIterations(3),
			new IncreasingMaxWithMin(new LinearIncreasingMax(0, 0), maxFrames, maxWords));}
	/**
	 * 
	 * @param data
	 * @param frameSize
	 * @param preMarkers
	 * @param postMarkers
	 * @param maxFrames
	 * @param maxWords
	 * @param sc
	 */
	protected FunctionalWordIdentifier(Corpus<WordAndTagHolder> data,
			int frameSize, int preMarkers, int postMarkers, int maxFrames, int maxWords,Scorer sc)
	{super(data, frameSize, preMarkers, postMarkers, sc, new ConvergenceByIterations(3),
			new IncreasingMaxWithMin(new LinearIncreasingMax(0, 0), maxFrames, maxWords));}
	/* (non-Javadoc)
	 * @see com.gragra.nounIdentification.BaseNounIdentifier#createStatistics(com.gragra.data.Corpus, int, int, int)
	 */
	@Override
	protected StatisticsGenerator createStatistics(
			Corpus<WordAndTagHolder> data, int frameSize, int preMarkers,
			int postMarkers)
	{return new CoOccurrenceStatistics(data, frameSize, preMarkers, postMarkers);}
	/* (non-Javadoc)
	 * @see com.gragra.nounIdentification.BaseNounIdentifier#getAssociatedType()
	 */
	@Override
	protected ExtensionInformationValue getAssociatedType()
	{return WordType.Function;}
	/* (non-Javadoc)
	 * @see com.gragra.nounIdentification.BaseNounIdentifier#decideTypePresent(com.gragra.sampling.sequentialStructure.WordAndTagHolder, int)
	 */
	@Override
	protected boolean decideTypePresent(WordAndTagHolder wth, int j)
	{return this.nouns.contains(wth.getWord(j));}
	/* (non-Javadoc)
	 * @see com.gragra.nounIdentification.BaseNounIdentifier#annotateEntryWord(com.gragra.data.Corpus, int)
	 */
	@Override
	protected void annotateEntryWord(Corpus<WordAndTagHolder> data2, int i)
	{
		WordAndTagHolder wth = data2.getEntry(i);
		{
			ExtensionInformationHolder eih = wth.getExtensionInformation();
			for(int k=0;k<wth.getLength();++k)
			{
				if(this.nouns.contains(wth.getWord(k)))
				{eih.addInformation(k, ExtensionLevels.WordTypeLevel, WordType.Function);}
			}
		}
	}
}